﻿using System;
using System.Collections.Generic;
using Character;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.EventSystems;

// Token: 0x02000208 RID: 520
public class HMaleShowChangeUIManager : MonoBehaviour
{
	// Token: 0x06000E3E RID: 3646 RVA: 0x00058EBC File Offset: 0x000570BC
	private void Awake()
	{
		this.mainToggle.ActionAddListener(new UnityAction<bool>(this.OnChangeMainToggle));
		this.hideableRoot.SetActive(false);
	}

	// Token: 0x06000E3F RID: 3647 RVA: 0x00058EE4 File Offset: 0x000570E4
	private void Update()
	{
		this.Update_ShortCutKeys();
	}

	// Token: 0x06000E40 RID: 3648 RVA: 0x00058EEC File Offset: 0x000570EC
	private void Update_ShortCutKeys()
	{
		if (EventSystem.current != null && EventSystem.current.currentSelectedGameObject != null)
		{
			return;
		}
		if (Input.GetKeyDown(KeyCode.Alpha1))
		{
			Male male = this.uis[0].GetMale();
			SystemSE.Play(SystemSE.SE.CHOICE);
			MALE_SHOW show = (MALE_SHOW)((int)(male.MaleShow + 1) % (int)MALE_SHOW.NUM);
			male.ChangeMaleShow(show);
			this.RecordMaleShow(male);
			this.UpdateToggles();
		}
		if (Input.GetKeyDown(KeyCode.Alpha5))
		{
			Male male2 = this.uis[1].GetMale();
			if (male2 != null)
			{
				SystemSE.Play(SystemSE.SE.CHOICE);
				MALE_SHOW show2 = (MALE_SHOW)((int)(male2.MaleShow + 1) % (int)MALE_SHOW.NUM); 
				for (int i = 1; i < this.uis.Length; i++)
				{
					Male male3 = this.uis[i].GetMale();
					if (male3 != null)
					{
						male3.ChangeMaleShow(show2);
						this.RecordMaleShow(male3);
					}
				}
				this.UpdateToggles();
			}
		}
	}

	// Token: 0x06000E41 RID: 3649 RVA: 0x00058FE8 File Offset: 0x000571E8
	public void Setup(H_Scene h_scene)
	{
		for (int i = 0; i < this.uis.Length; i++)
		{
			this.uis[i].Setup(h_scene);
		}
	}

	// Token: 0x06000E42 RID: 3650 RVA: 0x0005901C File Offset: 0x0005721C
	public void SetMales(List<Male> males)
	{
		for (int i = 0; i < this.uis.Length; i++)
		{
			Male male = (i >= males.Count) ? null : males[i];
			this.uis[i].SetMale(male);
			this.uis[i].gameObject.SetActive(male != null);
		}
	}

	// Token: 0x06000E43 RID: 3651 RVA: 0x00059084 File Offset: 0x00057284
	private void OnChangeMainToggle(bool change)
	{
		this.hideableRoot.SetActive(change);
		if (change)
		{
			this.UpdateToggles();
		}
	}

	// Token: 0x06000E44 RID: 3652 RVA: 0x000590A0 File Offset: 0x000572A0
	private void UpdateToggles()
	{
		for (int i = 0; i < this.uis.Length; i++)
		{
			this.uis[i].UpdateToggles();
		}
	}

	// Token: 0x06000E45 RID: 3653 RVA: 0x000590D4 File Offset: 0x000572D4
	private void RecordMaleShow(Male male)
	{
		GlobalData.maleShows[(int)male.MaleID] = male.MaleShow;
	}

	// Token: 0x04000EBB RID: 3771
	[SerializeField]
	private ToggleButton mainToggle;

	// Token: 0x04000EBC RID: 3772
	[SerializeField]
	private GameObject hideableRoot;

	// Token: 0x04000EBD RID: 3773
	[SerializeField]
	private HMaleShowChangeUI[] uis = new HMaleShowChangeUI[4];

	// Token: 0x04000EBE RID: 3774
	private List<Male> males;
}
